<template>
  <div>
      <mc-api-origin max-height="300px" :show-api="true" :show-db="true" :show-fields="true":data="data" @choose="choose" :project-uuid="projectUuid"></mc-api-origin>
      <mc-api :data="apiData" @save-data="saveData" :fields="fields" :show-fields="true"></mc-api>
      <el-button @click="print">打印</el-button>
  </div>
</template>

<script>
import McApiOrigin from './components/McApiOrigin'
import McApi from './components/McApi'
export default {
    data(){
      return {
          projectUuid:"402880ea7b7843a2017b784a66290001",
          data:{
             stage:"db",//api|db
             apiUuid:"",
             tableUuid:""
          },
          apiData:{
              method:"post",//post|get
              url:"",//
              params:[],//name入参名 compare:比较符号 value:值 type:number,string
              fields:[]//返回的字段
          },
          fields:[]
		  }
    },
    components:{
      McApiOrigin,
      McApi,
    },
    methods:{
        choose(val){
            if(val.stage=='db'){
                this.fields = val.fields;
                this.apiData.url = "magical_lowcode/openapi/crud/"+val.tableName+"/list";
            }else{
                this.fields = [];
                this.apiData.url = "magical_lowcode/openapi/post/"+val.apiUuid;
            }
        },
        saveData(val){
            console.log(val)
        },
        print(){
            console.log(this.apiData)
        }
    }
}
</script>

<style>

</style>
